import defaultSettings from '@/settings'
import variables from '@/styles/element-variables.scss'

const { showSettings, fixedHeader, sidebarLogo, tagsView, unreadMsgNumMark, unreadMsgNumMarkTime } = defaultSettings

const state = {
  theme: variables.theme,
  showSettings: showSettings, // 显示设置
  fixedHeader: fixedHeader, // 固定表头
  sidebarLogo: sidebarLogo, // 显示logo
  tagsView: tagsView, // 显示快捷导航栏
  unreadMsgNumMark: unreadMsgNumMark, // 未读消息数目提醒
  unreadMsgNumMarkTime: (!unreadMsgNumMarkTime) ? 5 : unreadMsgNumMarkTime // 获取未读消息时间间隔
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

